package faceService;

import com.qcloud.image.ImageClient;
import com.qcloud.image.common_utils.CommonFileUtils;
import com.qcloud.image.demo.Demo;
import com.qcloud.image.request.FaceVerifyRequest;
import util.AppContast;

import java.util.logging.Level;
import java.util.logging.Logger;

import static com.qcloud.image.http.RequestBodyKey.BUCKET;

/**
 * Created by Administrator on 2017/9/28.
 */
public class VerifyFace {
    public void verifyFace(String imgPath, String personId) {
        ImageClient imageClient = new ImageClient(AppContast.APP_ID, AppContast.SERCET_ID, AppContast.SERCET_KEY);
        String bucketName = BUCKET;

        String faceVerifyName  = "";
        String faceVerifyImage = "";
        String faceVerifyPersonId = personId;
        try {
            faceVerifyName = "";
            faceVerifyImage = CommonFileUtils.getFileContent(imgPath);
        } catch (Exception ex) {
            Logger.getLogger(Demo.class.getName()).log(Level.SEVERE, null, ex);
        }

        FaceVerifyRequest faceVerifyReq = new FaceVerifyRequest(bucketName, faceVerifyPersonId, faceVerifyName, faceVerifyImage);
        String ret = imageClient.faceVerify(faceVerifyReq);
        System.out.println(personId + " verify ret:" + ret);
    }
}
